package com.itclass.auth.controller;

import com.alibaba.fastjson2.JSON;
import com.itclass.auth.context.AuthServerApplicationContext;
import com.itclass.auth.pojo.db.Result;
import com.itclass.auth.pojo.dto.GitHubAuthDTO;
import com.itclass.auth.util.HttpClientUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;


@Controller
public class AuthController {
    @Autowired
    private AuthServerApplicationContext serverApplicationContext;
    @RequestMapping("/auth/github")
    @ResponseBody
    public Result github() {
        StringBuilder sb = new StringBuilder();
        sb.append("https://github.com/login/oauth/authorize?client_id=");
        sb.append(serverApplicationContext.getClientId());
        sb.append("&redirect_uri=");
        sb.append(serverApplicationContext.getRedirectUri());
        sb.append("&login=github");
        return Result.ok(sb.toString());
    }
}
